// pages/afterSaleCente/afterSaleCente.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    type: 0,
    choose: 0,

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    //获取手机高度
    this.setData({
      navH: app.globalData.navHeight,
    })
    wx.request({
      url: app.globalData.url + 'getUserStoredValueCardList',
      method: 'GET',
      data: {
        status: 7001,
        userId: wx.getStorageSync("userId")
      },
      success: function (res) {
        that.setData({
          list: res.data.data
        });
      },
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.onLoad();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  navBack: function () {
    wx.navigateBack({
    })
  },
  choose: function (e) {
    var that = this;
    this.setData({
      choose: e.currentTarget.dataset.index
    })
    if (e.currentTarget.dataset.index == 0){
      wx.request({
        url: app.globalData.url + 'getUserStoredValueCardList',
        method: 'GET',
        data: {
          status:7001,
          userId: wx.getStorageSync("userId")
        },
        success: function (res) {
          that.setData({
            list:res.data.data
          });
        },
      });
    }else{
      wx.request({
        url: app.globalData.url + 'getUserStoredValueCardList',
        method: 'GET',
        data: {
          status: 7003,
          userId: wx.getStorageSync("userId")
        },
        success: function (res) {
          that.setData({
            list: res.data.data
          });
        },
      });
    }
  },
  goHR: function() {
    wx.navigateTo({
      url: '/pages/storedValueCardHR/storedValueCardHR',
    })
  },
  goDetail: function (e) {
    var card = JSON.stringify(this.data.list[e.currentTarget.dataset.ind]);
    wx.navigateTo({
      url: '/pages/storeValueCardDetail/storeValueCardDetail?card='+card
    })
  },
  /**
   * 页面分享
   */
  onShareAppMessage: function (e) {
    var that = this;
    return {
      title: '极味生鲜',
      desc: '储值卡赠送',
      imageUrl: that.data.list[e.currentTarget.dataset.index],
      path: '/pages/mallPage/mallPage?partnerUserId=' + wx.getStorageSync("userId") + '&giving=2&cardid=' + that.data.list[e.currentTarget.dataset.index].cardId + '&partnerUserName=' + wx.getStorageSync("nickName"), // 路径，传递参数到指定页面
      success(res) {
        
      }
    }
  },
  goLook:function(){
    wx.navigateBack({
      
    })
  },
})